<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-table :data="pager.lists" size="large">
                <el-table-column label="id" prop="id" min-width="100" />
                <el-table-column label="标题" prop="title" min-width="100" />
                <el-table-column label="内容" prop="text" min-width="100" />
                <el-table-column label="时间" prop="add_time" min-width="100" />
                <el-table-column label="操作" width="200" fixed="right">
                    <template #default="{ row }">
                        <el-button type="danger" link @click="handleDelete(row.id)">
                            删除
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>

<script lang="ts" setup>
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import { delMessage, getMessage, } from '@/api/application/website/leave'

const formData = reactive({

})
const { pager, getLists , resetParams, resetPage } = usePaging({
    fetchFun: getMessage,
    params: formData
})

const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    await delMessage({ id })
    getLists()
}
getLists()
</script>
